home *** CD-ROM | disk | FTP | other *** search
/ Champak 103 / Vol 103.iso / games / starship.swf / scripts / DefineSprite_34 / frame_3 / DoAction.as
Text File  |  2010-03-13  |  3KB  |  153 lines

  1. actSpeed = 0;
  2. vx *= _root.cst.slowdown;
  3. collision = 0;
  4. legL = false;
  5. legR = false;
  6. legC = false;
  7. if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0],true))
  8. {
  9.    collision++;
  10.    legL = true;
  11. }
  12. if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1],true))
  13. {
  14.    collision++;
  15.    legR = true;
  16. }
  17. if(_parent.matter.platform.hitTest(_X + sensorX[2],_Y + sensorY[2],true))
  18. {
  19.    collision++;
  20.    legC = true;
  21. }
  22. if(legL == true && legR != true)
  23. {
  24.    if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1] + 3.5,true))
  25.    {
  26.       rotate = 2;
  27.       maxrotate = 5;
  28.    }
  29.    else
  30.    {
  31.       rotate = 3;
  32.       maxrotate = 10;
  33.    }
  34. }
  35. if(legR == true && legL != true)
  36. {
  37.    if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0] + 3.5,true))
  38.    {
  39.       rotate = -2;
  40.       maxrotate = 5;
  41.    }
  42.    else
  43.    {
  44.       rotate = -3;
  45.       maxrotate = 10;
  46.    }
  47. }
  48. if(legL != true && legR != true)
  49. {
  50.    rotate = 0;
  51. }
  52. if(1 < collision)
  53. {
  54.    ground = true;
  55.    fireLeft.gotoAndStop("inactive");
  56.    fireRight.gotoAndStop("inactive");
  57.    vy = 0;
  58.    vx = 0;
  59.    if(Math.abs(_rotation) < maxrotate && rotate != 0)
  60.    {
  61.       _rotation = _rotation + rotate;
  62.       _Y = _Y + 0.2;
  63.    }
  64.    i = 5;
  65.    while(6 >= i)
  66.    {
  67.       bump();
  68.       i++;
  69.    }
  70. }
  71. else
  72. {
  73.    ground = false;
  74.    _rotation = _rotation * 0.9;
  75.    vy += _root.cst.gravity;
  76. }
  77. completeCollisionCheck();
  78. if(collision == true)
  79. {
  80.    collision = false;
  81.    i = 5;
  82.    while(9 >= i)
  83.    {
  84.       if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  85.       {
  86.          bump();
  87.       }
  88.       i++;
  89.    }
  90. }
  91. checkBorderCollision();
  92. if(Key.isDown(Key.UP))
  93. {
  94.    vy += ay;
  95.    fireDown.gotoAndStop("fire");
  96. }
  97. else
  98. {
  99.    fireDown.gotoAndStop("inactive");
  100. }
  101. if(Key.isDown(Key.LEFT))
  102. {
  103.    if(ground == true)
  104.    {
  105.       vy += ay;
  106.    }
  107.    vx -= ax;
  108.    fireRight.gotoAndStop("fire");
  109.    _rotation = _rotation * 0.98 + 1;
  110.    shootLeft = true;
  111. }
  112. else
  113. {
  114.    fireRight.gotoAndStop("inactive");
  115. }
  116. if(Key.isDown(Key.RIGHT))
  117. {
  118.    if(ground == true)
  119.    {
  120.       vy += ay;
  121.    }
  122.    vx += ax;
  123.    fireLeft.gotoAndStop("fire");
  124.    _rotation = _rotation * 0.98 - 1;
  125.    shootLeft = false;
  126. }
  127. else
  128. {
  129.    fireLeft.gotoAndStop("inactive");
  130. }
  131. _X = _X + vx;
  132. _Y = _Y + vy;
  133. if(Key.isDown(Key.SPACE))
  134. {
  135.    if(_parent.shot.ready == true)
  136.    {
  137.       if(shootLeft != true)
  138.       {
  139.          _parent.shot._x = _X + 15;
  140.          _parent.shot._y = _Y - 8;
  141.          _parent.shot.vx = 3;
  142.       }
  143.       else
  144.       {
  145.          _parent.shot._x = _X - 15;
  146.          _parent.shot._y = _Y - 8;
  147.          _parent.shot.vx = -3;
  148.       }
  149.       _parent.shot.ready = false;
  150.       _parent.shot.gotoAndPlay("shoot");
  151.    }
  152. }
  153.